package com.lagou.module4.work03;

public class TicketTest {

    //火车买票案例 (两种实现方式) : 共100张票,三个线程一起卖票,不允许出现出现负票和多卖的现象
    public static void main(String[] args) {

        //第一种继承Thread
       /* Ticket ticket = new Ticket(100);

        TicketThread1 T1 = new TicketThread1(ticket);
        TicketThread2 T2 = new TicketThread2(ticket);
        TicketThread3 T3 = new TicketThread3(ticket);

        T1.start();
        T2.start();
        T3.start();*/

        //第二种实现Runnable接口
        Ticket ticket = new Ticket(100);

        TicketRunnable1 t01 = new TicketRunnable1(ticket);
        Thread t1 = new Thread(t01);
        TicketRunnable2 t02 = new TicketRunnable2(ticket);
        Thread t2 = new Thread(t02);
        TicketRunnable3 t03 = new TicketRunnable3(ticket);
        Thread t3 = new Thread(t03);
        t1.start();
        t2.start();
        t3.start();
    }

}
